import { BaseWindow } from "../../../../component/window/BaseWindow";
import { Language } from "../../../../../extend/language/Language";
import { ObjCreate } from "../../common/ObjCreate";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { PageSelecter } from "../../common/pageSelect/PageSelecter";
import { TilePanel } from "../../equipment/TilePanel";
import { ArenaCrossFinalStatusRankCellRenderer } from "./cell/ArenaCrossFinalStatusRankCellRenderer";
import { SArenaCrossBetToplists } from "../../../../../Message/Public/SArenaCrossBetToplists";
import { DataProvider } from "../../../../../fl/data/DataProvider";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { _page } from "../../../../../this/_page";
import { _pageSize } from "../../../../../this/_pageSize";
type int = number;
//class ArenaCrossFinalStatusRankWindow
    
    export  class ArenaCrossFinalStatusRankWindow extends BaseWindow
    {
        constructor()
        {
            super();
            setSize(500, 440);
            title = Language.getString(44324);
            titleHeight = 27;
            addEventListener(flash.events.Event.ADDED_TO_STAGE, this.onAddToStageHandler);
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            this._sp = new Object /* flash.display.Sprite */();
            this._sp.x = 18;
            this._sp.y = 38;
            addChild(this._sp);
            ObjCreate.createBg(0, 0, 464, 368, this._sp);
            ObjCreate.createTextField(Language.getString(44325), 50, 8, 36, 20, this._sp, GlobalStyle.textFormat6);
            ObjCreate.createTextField(Language.getString(44326), 205, 8, 36, 20, this._sp, GlobalStyle.textFormat6);
            ObjCreate.createTextField(Language.getString(44327), 373, 8, 36, 20, this._sp, GlobalStyle.textFormat6);
            this._pageBar = new PageSelecter();
            this._pageBar.mode = PageSelecter.CompleteMode;
            this._pageBar.move(165, 371);
            this._pageBar.addEventListener(flash.events.Event.CHANGE, this.onPageBarChange);
            this._sp.addChild(this._pageBar);
            this._tfNoRecord = ObjCreate.createTextField(Language.getString(44240), 218, 208, 200, 20, this, GlobalStyle.textFormat6);
            this._tfNoRecord.visible = true;
            this._rankList = new TilePanel();
            this._rankList.setSize(455, 330);
            this._rankList.rowHeight = 33;
            this._rankList.columnWidth = 450;
            this._rankList.setStyle("cellRenderer", ArenaCrossFinalStatusRankCellRenderer);
            this._rankList.x = 3;
            this._rankList.y = 28;
            this._sp.addChild(this._rankList);
            this._rankList.visible = false;
            return;
        }

        public updateInfo(arg1: SArenaCrossBetToplists): void
        {
            this._info = arg1;
            if (this._info == null || this._info.toplists.length == 0) 
            {
                this._rankList.visible = false;
                this._tfNoRecord.visible = true;
            }
            else 
            {
                this._rankList.visible = true;
                this._tfNoRecord.visible = false;
                this._pageBar.maxPage = arg1.pageNum;
                this._rankList.dataProvider = new DataProvider(this._info.toplists);
            }
            return;
        }

        protected onAddToStageHandler(arg1: Object /* flash.events.Event */): void
        {
            this.sendPageChange();
            return;
        }

        protected onPageBarChange(arg1: Object /* flash.events.Event */): void
        {
            this._page = this._pageBar.currentPage;
            this.sendPageChange();
            return;
        }

        /* internal  */sendPageChange(): void
        {
            var loc1={"page": _page, "pageSize": _pageSize};
            Dispatcher.dispatchEvent(new DataEvent(EventName.ArenaCrossGetStatusInfos, loc1));
            return;
        }

        public static get instance(): ArenaCrossFinalStatusRankWindow
        {
            if (!ArenaCrossFinalStatusRankWindow._instance) 
            {
                ArenaCrossFinalStatusRankWindow._instance = new ArenaCrossFinalStatusRankWindow();
            }
            return ArenaCrossFinalStatusRankWindow._instance;
        }

        /* internal */ /* var */_sp: Object /* flash.display.Sprite */;

        /* internal */ /* var */_rankTx: Object /* flash.text.TextField */;

        /* internal */ /* var */_nameTx: Object /* flash.text.TextField */;

        /* internal */ /* var */_valueTx: Object /* flash.text.TextField */;

        /* internal */ /* var */_pageBar: PageSelecter;

        /* internal */ /* var */_tfNoRecord: Object /* flash.text.TextField */;

        /* internal */ /* var */_rankList: TilePanel;

        /* internal */ /* var */_page: int=1;

        /* internal */ /* var */_pageSize: int=10;

        /* internal */ /* var */_info: SArenaCrossBetToplists;

        /* internal */ static /* var */_instance: ArenaCrossFinalStatusRankWindow;
    }
